from flask import render_template, request, redirect
from majesty.app.common.common import get_menu
from majesty.app.model.auth_group import AuthGroup
from majesty.app.model.classes_type import ClassesType
from majesty.app.model.member import Member
from majesty.app import member


@member.route("/member/index")
def index():
    member = Member()
    rs = member.select_all()
    menu = get_menu()
    return render_template('member/index.html', rs=rs, menu=menu)


@member.route("/member/add")
def add():
    menu = get_menu()

    group = AuthGroup()
    rs = group.select_all()

    type = ClassesType()
    data = type.select_all()

    return render_template('member/add.html', data=data,rs=rs,menu=menu)

#
# @status.route("/status/insert", methods=['post'])
# def insert():
#     data = {
#         'name': request.form.get('name')
#     }
#     status = Status(**data)
#     db.session.add(status)
#     return redirect('/status/index')
#
#
# @status.route("/status/edit/id/<id>")
# def edit(id):
#     menu = get_menu()
#     result = Status.query.filter_by(id=id).first()
#     return render_template('status/edit.html', result=result, menu=menu)
#
#
# @status.route("/status/update", methods=['post'])
# def update():
#     id = request.form.get('id')
#     data = {
#         'name': request.form.get('name')
#     }
#     Status.query.filter_by(id=id).update(data)
#     return redirect('/status/index')
#
#
# @status.route("/status/delete/id/<id>")
# def delete(id):
#     Status.query.filter_by(id=id).delete()
#     return redirect('/status/index')
